package com.apes.fn.business.insurance.modle;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.frame.model.Dept;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * @ClassName InsuranceCommissionItem
 * @Author wsj
 * @Date 2021/6/21 17:06
 * @description 保险公司佣金明细
 */

@Entity
@EntityListeners(DefaultPersistListener.class)
@Getter
@Setter
@Table(name = InsuranceCommissionItem.CONST_TABLE_NAME)
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
public class InsuranceCommissionItem extends BaseModel {
    public final static String CONST_TABLE_NAME = "insurance_commission_item";

    @Id
    @Column(name = "id", nullable = false,length = 24)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "保险公司佣金明细")
    @Comment("明细序列")
    private String id;

    @ManyToOne(optional = false)
    @JoinColumn(name = "commission_Reconciliation",referencedColumnName = "id",nullable = false)
    private CommissionReconciliation commissionReconciliation;


    @Column(name = "policy_Number",length = 64)
    @Comment("保单号")
    private String policyNumber;

    @Column(name = "car_License",length = 64)
    @Comment("车牌")
    private String carLicense;

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "start_Date")
    @Comment("起保时间")
    private Date startDate;

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "end_Date")
    @Comment("终保时间")
    private Date endDate;

    @Comment("净保费")
    @Column(name = "net_Premium",nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private Double netPremium;

    @Comment("佣金比率")
    @Column(name = "commission_Ratio",nullable = false, columnDefinition = ApesConst.FIELD_ROUND_16_8)
    private double commissionRatio = 0;

    @Comment("佣金金额")
    @Column(name = "commission",nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double commission = 0 ;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "dept_id", referencedColumnName = "id")
    @Comment("门店")
    private Dept dept;

    @Column(name = "insurance_Type", length = 32)
    @Comment("险种类别(0:商业险,1：交强险,2:驾意险)")
    private String insuranceType;

    @Column(name = "city", length = 32)
    @Comment("城市名称")
    private String city;

    @Column(name = "province", length = 32)
    @Comment("省份")
    private String province;
}
